<?php

namespace modules\joyshop;

use app\common\library\Menu;
use app\shop\command\AutoCancelOrder;
use app\shop\command\AutoEvaluateOrder;
use app\shop\command\AutoExpireCoupon;
use app\shop\command\AutoReceiveOrder;
use app\shop\events\user\UserRegisterEvent;
use ba\Exception;
use ba\Terminal;
use think\facade\Console;
use think\facade\Event;

class Joyshop
{
    public function AppInit(): void
    {
        // 注册命令行
        if (request()->isCli()) {
            Console::starting(function (\think\Console $console) {
                $console->addCommands([
                    AutoCancelOrder::class,
                    AutoReceiveOrder::class,
                    AutoEvaluateOrder::class,
                    AutoExpireCoupon::class
                ]);
            });
        }

        // 事件监听
        Event::listen('UserRegisterEvent', UserRegisterEvent::class);
    }

    /**
     * 安装
     */
    public function install(): void
    {
        Menu::create($this->getMenu());
    }

    /**
     * 卸载
     */
    public function uninstall(): void
    {
        // 删除添加的菜单
        Menu::delete('shop', true);
    }

    /**
     * 启用
     */
    public function enable(): void
    {
        $this->migrate();

        Menu::enable('shop');
    }

    /**
     * 禁用
     */
    public function disable(): void
    {
        Menu::disable('shop');
    }

    /**
     * 更新
     */
    public function update()
    {
        Menu::create($this->getMenu());
    }

    public function getMenu(): array
    {
        return [
            [
                'type'      => 'menu_dir',
                'title'     => 'JoyShop商城',
                'name'      => 'shop',
                'path'      => 'shop',
                'icon'      => 'el-icon-Shop',
                'keepalive' => '1',
                'weigh'     => 9999,
                'children'  => [
                    [
                        'type'      => 'menu',
                        'title'     => '控制台',
                        'name'      => 'shop/dashboard',
                        'path'      => 'shop/dashboard',
                        'icon'      => 'fa fa-dashboard',
                        'menu_type' => 'tab',
                        'component' => '/src/views/backend/shop/dashboard.vue',
                        'keepalive' => '0',
                        'weigh'     => 999,
                        'children'  => [
                            ['type' => 'button', 'title' => '查看', 'name' => 'shop/dashboard/index'],
                        ]
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '广告位管理',
                        'name'      => 'shop/advert',
                        'path'      => 'shop/advert',
                        'icon'      => 'fa fa-buysellads',
                        'keepalive' => '0',
                        'children'  => $this->advertChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '商品管理',
                        'name'      => 'shop/goods',
                        'path'      => 'shop/goods',
                        'icon'      => 'fa fa-shopping-bag',
                        'keepalive' => '0',
                        'children'  => $this->goodsChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '订单管理',
                        'name'      => 'shop/order',
                        'path'      => 'shop/order',
                        'icon'      => 'el-icon-List',
                        'keepalive' => '0',
                        'children'  => $this->orderChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '用户管理',
                        'name'      => 'shop/user',
                        'path'      => 'shop/user',
                        'icon'      => 'fa fa-drivers-license',
                        'keepalive' => '0',
                        'children'  => $this->userChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '物流管理',
                        'name'      => 'shop/delivery',
                        'path'      => 'shop/delivery',
                        'icon'      => 'fa fa-truck',
                        'keepalive' => '0',
                        'children'  => $this->deliveryChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '营销管理',
                        'name'      => 'shop/market',
                        'path'      => 'shop/market',
                        'icon'      => 'fa fa-tags',
                        'keepalive' => '0',
                        'children'  => $this->marketChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '通知管理',
                        'name'      => 'shop/notify',
                        'path'      => 'shop/notify',
                        'icon'      => 'fa fa-bell',
                        'keepalive' => '0',
                        'children'  => $this->notifyChildren(),
                    ],
                    [
                        'type'      => 'menu_dir',
                        'title'     => '商城配置',
                        'name'      => 'shop/setting',
                        'path'      => 'shop/setting',
                        'icon'      => 'fa fa-cogs',
                        'keepalive' => '1',
                        'weight'    => 0,
                        'children'  => $this->settingChildren(),
                    ],
                ],
            ]
        ];
    }

    private function advertChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '轮播图管理',
                'name'      => 'shop/advert/banner',
                'path'      => 'shop/advert/banner',
                'icon'      => 'fa fa-picture-o',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/advert/banner/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/advert/banner/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/advert/banner/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/advert/banner/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/advert/banner/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/advert/banner/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '公告栏管理',
                'name'      => 'shop/advert/noticeBar',
                'path'      => 'shop/advert/noticeBar',
                'icon'      => 'fa fa-volume-up',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/advert/noticeBar/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/advert/noticeBar/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/advert/noticeBar/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/advert/noticeBar/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/advert/noticeBar/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/advert/noticeBar/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '热卖推荐管理',
                'name'      => 'shop/advert/hotRecommend',
                'path'      => 'shop/advert/hotRecommend',
                'icon'      => 'fa fa-columns',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/advert/hotRecommend/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/advert/hotRecommend/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/advert/hotRecommend/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/advert/hotRecommend/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/advert/hotRecommend/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/advert/hotRecommend/sortable'],
                ]
            ]
        ];
    }

    private function goodsChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '商品列表管理',
                'name'      => 'shop/goods/goods',
                'path'      => 'shop/goods/goods',
                'icon'      => 'el-icon-GoodsFilled',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/goods/goods/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/goods/goods/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/goods/goods/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/goods/goods/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/goods/goods/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/goods/goods/sortable'],
                    ['type' => 'button', 'title' => '修改库存', 'name' => 'shop/goods/goods/editStock'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '商品分类管理',
                'name'      => 'shop/goods/classify',
                'path'      => 'shop/goods/classify',
                'icon'      => 'fa fa-th-large',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/goods/classify/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/goods/classify/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/goods/classify/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/goods/classify/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/goods/classify/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/goods/classify/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '参数模板管理',
                'name'      => 'shop/goods/paramsTemplate',
                'path'      => 'shop/goods/paramsTemplate',
                'icon'      => 'fa fa-list-alt',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/goods/paramsTemplate/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/goods/paramsTemplate/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/goods/paramsTemplate/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/goods/paramsTemplate/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/goods/paramsTemplate/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/goods/paramsTemplate/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '规格模板管理',
                'name'      => 'shop/goods/specTemplate',
                'path'      => 'shop/goods/specTemplate',
                'icon'      => 'fa fa-list-alt',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/goods/specTemplate/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/goods/specTemplate/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/goods/specTemplate/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/goods/specTemplate/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/goods/specTemplate/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/goods/specTemplate/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '服务承诺管理',
                'name'      => 'shop/goods/service',
                'path'      => 'shop/goods/service',
                'icon'      => 'fa fa-list-alt',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/goods/service/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/goods/service/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/goods/service/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/goods/service/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/goods/service/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/goods/service/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '商品评价管理',
                'name'      => 'shop/order/evaluate',
                'path'      => 'shop/order/evaluate',
                'icon'      => 'fa fa-commenting',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/order/evaluate/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/order/evaluate/index'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/order/evaluate/edit'],
                ]
            ],
        ];
    }

    private function orderChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '订单管理',
                'name'      => 'shop/order/order',
                'path'      => 'shop/order/order',
                'icon'      => 'el-icon-List',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/order/order/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/order/order/index'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/order/order/del'],
                    ['type' => 'button', 'title' => '订单发货', 'name' => 'shop/order/delivery/delivery'],
                    ['type' => 'button', 'title' => '订单审核', 'name' => 'shop/order/order/cancel'],
                    ['type' => 'button', 'title' => '订单导出', 'name' => 'shop/order/order/addExportTask'],
                    ['type' => 'button', 'title' => '订单关闭', 'name' => 'shop/order/order/close'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '售后管理',
                'name'      => 'shop/order/refund',
                'path'      => 'shop/order/refund',
                'icon'      => 'el-icon-Service',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/order/refund/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/order/refund/index'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/order/refund/del'],
                    ['type' => 'button', 'title' => '售后审核', 'name' => 'shop/order/refund/audit'],
                    ['type' => 'button', 'title' => '售后收货', 'name' => 'shop/order/refund/receive'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '导出管理',
                'name'      => 'shop/order/export',
                'path'      => 'shop/order/export',
                'icon'      => 'fa fa-download',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/order/export/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/order/export/index'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/order/export/del'],
                    ['type' => 'button', 'title' => '下载文件', 'name' => 'shop/order/export/exportData'],
                    ['type' => 'button', 'title' => '重新运行', 'name' => 'shop/order/export/retryTask'],
                ]
            ],
        ];
    }

    private function userChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '用户管理',
                'name'      => 'shop/user/user',
                'path'      => 'shop/user/user',
                'icon'      => 'fa fa-user',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/user/user/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/user/user/index'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/user/user/edit'],
                    ['type' => 'button', 'title' => '调整余额', 'name' => 'shop/user/user/editBalance'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '余额管理',
                'name'      => 'shop/user/moneyLog',
                'path'      => 'shop/user/moneyLog',
                'icon'      => 'fa fa-money',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/user/moneyLog/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/user/moneyLog/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/user/moneyLog/add'],
                ]
            ],
        ];
    }

    private function deliveryChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '物流地址管理',
                'name'      => 'shop/delivery/address',
                'path'      => 'shop/delivery/address',
                'icon'      => 'el-icon-LocationFilled',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/delivery/address/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/delivery/address/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/delivery/address/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/delivery/address/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/delivery/address/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/delivery/address/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '物流公司管理',
                'name'      => 'shop/delivery/company',
                'path'      => 'shop/delivery/company',
                'icon'      => 'fa fa-building',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/delivery/company/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/delivery/company/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/delivery/company/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/delivery/company/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/delivery/company/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/delivery/company/sortable'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '运费模板管理',
                'name'      => 'shop/delivery/template',
                'path'      => 'shop/delivery/template',
                'icon'      => 'fa fa-list-alt',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/delivery/template/index.vue',
                'keepalive' => '1',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/delivery/template/index'],
                    ['type' => 'button', 'title' => '添加', 'name' => 'shop/delivery/template/add'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/delivery/template/edit'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/delivery/template/del'],
                    ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/delivery/template/sortable'],
                ]
            ],
        ];
    }

    private function marketChildren(): array
    {
        return [
            [
                'type'      => 'menu_dir',
                'title'     => '优惠券管理',
                'name'      => 'shop/market/coupon',
                'path'      => 'shop/market/coupon',
                'icon'      => 'el-icon-Ticket',
                'keepalive' => '1',
                'children'  => [
                    [
                        'type'      => 'menu',
                        'title'     => '优惠券管理',
                        'name'      => 'shop/market/coupon/coupon',
                        'path'      => 'shop/market/coupon/coupon',
                        'icon'      => 'fa fa-ticket',
                        'keepalive' => '1',
                        'menu_type' => 'tab',
                        'component' => '/src/views/backend/shop/market/coupon/coupon/index.vue',
                        'children'  => [
                            ['type' => 'button', 'title' => '查看', 'name' => 'shop/market/coupon/coupon/index'],
                            ['type' => 'button', 'title' => '添加', 'name' => 'shop/market/coupon/coupon/add'],
                            ['type' => 'button', 'title' => '编辑', 'name' => 'shop/market/coupon/coupon/edit'],
                            ['type' => 'button', 'title' => '删除', 'name' => 'shop/market/coupon/coupon/del'],
                        ]
                    ],
                    [
                        'type'      => 'menu',
                        'title'     => '领券中心管理',
                        'name'      => 'shop/market/coupon/center',
                        'path'      => 'shop/market/coupon/center',
                        'icon'      => 'fa fa-tag',
                        'keepalive' => '1',
                        'menu_type' => 'tab',
                        'component' => '/src/views/backend/shop/market/coupon/center/index.vue',
                        'children'  => [
                            ['type' => 'button', 'title' => '查看', 'name' => 'shop/market/coupon/center/index'],
                            ['type' => 'button', 'title' => '添加', 'name' => 'shop/market/coupon/center/add'],
                            ['type' => 'button', 'title' => '删除', 'name' => 'shop/market/coupon/center/del'],
                            ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/market/coupon/center/sortable'],
                        ]
                    ],
                    [
                        'type'      => 'menu',
                        'title'     => '领券记录管理',
                        'name'      => 'shop/market/coupon/receive',
                        'path'      => 'shop/market/coupon/receive',
                        'icon'      => 'fa fa-list',
                        'keepalive' => '1',
                        'menu_type' => 'tab',
                        'component' => '/src/views/backend/shop/market/coupon/receive/index.vue',
                        'children'  => [
                            ['type' => 'button', 'title' => '查看', 'name' => 'shop/market/coupon/receive/index'],
                            ['type' => 'button', 'title' => '添加', 'name' => 'shop/market/coupon/receive/add'],
                            ['type' => 'button', 'title' => '编辑', 'name' => 'shop/market/coupon/receive/edit'],
                            ['type' => 'button', 'title' => '删除', 'name' => 'shop/market/coupon/receive/del'],
                            ['type' => 'button', 'title' => '还原', 'name' => 'shop/market/coupon/receive/restore'],
                        ]
                    ],
                ]
            ],
            [
                'type'      => 'menu_dir',
                'title'     => '充值中心管理',
                'name'      => 'shop/market/recharge',
                'path'      => 'shop/market/recharge',
                'icon'      => 'fa fa-rmb',
                'keepalive' => '1',
                'children'  => [
                    [
                        'type'      => 'menu',
                        'title'     => '充值套餐管理',
                        'name'      => 'shop/market/recharge/plan',
                        'path'      => 'shop/market/recharge/plan',
                        'icon'      => 'fa fa-table',
                        'keepalive' => '1',
                        'menu_type' => 'tab',
                        'component' => '/src/views/backend/shop/market/recharge/plan/index.vue',
                        'children'  => [
                            ['type' => 'button', 'title' => '查看', 'name' => 'shop/market/recharge/plan/index'],
                            ['type' => 'button', 'title' => '添加', 'name' => 'shop/market/recharge/plan/add'],
                            ['type' => 'button', 'title' => '编辑', 'name' => 'shop/market/recharge/plan/edit'],
                            ['type' => 'button', 'title' => '删除', 'name' => 'shop/market/recharge/plan/del'],
                            ['type' => 'button', 'title' => '快速排序', 'name' => 'shop/market/recharge/plan/sortable'],
                        ]
                    ],
                    [
                        'type'      => 'menu',
                        'title'     => '充值订单管理',
                        'name'      => 'shop/market/recharge/order',
                        'path'      => 'shop/market/recharge/order',
                        'icon'      => 'el-icon-List',
                        'keepalive' => '1',
                        'menu_type' => 'tab',
                        'component' => '/src/views/backend/shop/market/recharge/order/index.vue',
                        'children'  => [
                            ['type' => 'button', 'title' => '查看', 'name' => 'shop/market/recharge/order/index'],
                            ['type' => 'button', 'title' => '添加', 'name' => 'shop/market/recharge/order/add'],
                            ['type' => 'button', 'title' => '编辑', 'name' => 'shop/market/recharge/order/edit'],
                            ['type' => 'button', 'title' => '删除', 'name' => 'shop/market/recharge/order/del'],
                        ]
                    ],
                ]
            ]
        ];
    }

    private function notifyChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '通知列表管理',
                'name'      => 'shop/notify/notify',
                'path'      => 'shop/notify/notify',
                'icon'      => 'fa fa-commenting',
                'keepalive' => '0',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/notify/notify/index.vue',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/notify/notify/index'],
                    ['type' => 'button', 'title' => '删除', 'name' => 'shop/notify/notify/del'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '通知配置管理',
                'name'      => 'shop/notify/notifyConfig',
                'path'      => 'shop/notify/notifyConfig',
                'icon'      => 'fa fa-cog',
                'keepalive' => '1',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/notify/notifyConfig/index.vue',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/notify/notifyConfig/index'],
                    ['type' => 'button', 'title' => '编辑', 'name' => 'shop/notify/notifyConfig/edit'],
                ]
            ]
        ];
    }

    private function settingChildren(): array
    {
        return [
            [
                'type'      => 'menu',
                'title'     => '基本配置',
                'name'      => 'shop/setting/basic',
                'path'      => 'shop/setting/basic',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/setting/basic/index.vue',
                'keepalive' => '1',
                'icon'      => 'el-icon-Tools',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/setting/basic/index'],
                    ['type' => 'button', 'title' => '保存', 'name' => 'shop/setting/basic/save'],
                    ['type' => 'button', 'title' => '查看敏感数据', 'name' => 'shop/setting/basic/getSensitiveFieldValue'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '小程序配置',
                'name'      => 'shop/setting/miniapp',
                'path'      => 'shop/setting/miniapp',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/setting/miniapp/index.vue',
                'keepalive' => '1',
                'icon'      => 'fa fa-wechat',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/setting/miniapp/index'],
                    ['type' => 'button', 'title' => '保存', 'name' => 'shop/setting/miniapp/save'],
                    ['type' => 'button', 'title' => '查看敏感数据', 'name' => 'shop/setting/miniapp/getSensitiveFieldValue'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '支付配置',
                'name'      => 'shop/setting/pay',
                'path'      => 'shop/setting/pay',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/setting/pay/index.vue',
                'keepalive' => '1',
                'icon'      => 'fa fa-cc-paypal',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/setting/pay/index'],
                    ['type' => 'button', 'title' => '保存', 'name' => 'shop/setting/pay/save'],
                    ['type' => 'button', 'title' => '查看敏感数据', 'name' => 'shop/setting/pay/getSensitiveFieldValue'],
                ]
            ],
            [
                'type'      => 'menu',
                'title'     => '协议配置',
                'name'      => 'shop/setting/agreement',
                'path'      => 'shop/setting/agreement',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/setting/agreement/index.vue',
                'keepalive' => '1',
                'icon'      => 'fa fa-handshake-o',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/setting/agreement/index'],
                    ['type' => 'button', 'title' => '保存', 'name' => 'shop/setting/agreement/save'],
                    ['type' => 'button', 'title' => '查看敏感数据', 'name' => 'shop/setting/agreement/getSensitiveFieldValue'],
                ],
            ],
            [
                'type'      => 'menu',
                'title'     => '物流配置',
                'name'      => 'shop/setting/delivery',
                'path'      => 'shop/setting/delivery',
                'menu_type' => 'tab',
                'component' => '/src/views/backend/shop/setting/delivery/index.vue',
                'keepalive' => '1',
                'icon'      => 'fa fa-truck',
                'children'  => [
                    ['type' => 'button', 'title' => '查看', 'name' => 'shop/setting/delivery/index'],
                    ['type' => 'button', 'title' => '保存', 'name' => 'shop/setting/delivery/save'],
                    ['type' => 'button', 'title' => '查看敏感数据', 'name' => 'shop/setting/delivery/getSensitiveFieldValue'],
                ]
            ],
        ];
    }

    /**
     * @throws Exception
     */
    private function migrate(): void
    {
        // 切换到项目根目录
        chdir(root_path());

        if (!Terminal::getOutputFromProc('migrate.run')) {
            throw new Exception('数据迁移失败');
        }
    }
}